<docs>
  ## 编辑教育经历
</docs>
<template>
  <div class="wrap">
    <div class="header">
      <span class="arrow" @click="back_btn"></span>
      <h3 class="title">教育经历</h3>
    </div>
    <div class="common">
      <div class="title tem_comm">
        <p>教育经历</p>
        <div class="group">
          <i class="iconfont icon-add" @click="editLink(1,'40')"></i>
        </div>
      </div>
      <div v-for="(item, index) in xxjl" :key="index">
        <div class="point tem_comm">
          <div class="group">
            <i class="iconfont icon-delete" @click="deleteData('40',item)"></i>
            <i class="iconfont icon-edit" @click="editLink(2,'40',item)"></i>
          </div>
          <!-- <div class="circle"></div> -->
            <div class="item">
              <span class="list_l">入学时间</span>
              <span class="list_r">{{item.rxsj}}</span>
            </div>
            <div class="item">
              <span class="list_l duiqi">毕业时间</span>
              <span class="list_r">{{item.bysj}}</span>
            </div>
            <div class="item">
              <span class="list_l">毕业院校</span>
              <span class="list_r">{{item.byyx}}</span>
            </div>
            <div class="item">
              <span class="list_l">所属学历</span>
              <span class="list_r">{{item.whcd_xs}}</span>
            </div>
            <div class="item" v-if="item.sxzy_xs">
              <span class="list_l">所学专业</span>
              <span class="list_r">{{item.sxzy_xs}}</span>
            </div>
            <div class="item" v-if="item.xxjlbz">
              <span class="list_l">备注</span>
              <span class="list_r">{{item.xxjlbz}}</span>
            </div>
        </div>
      </div>
    </div>

    <!-- 职业技能开始 -->
    <div class="common">
      <div class="title tem_comm">
        <p>职业技能</p>
        <div class="group">
          <i class="iconfont icon-add" @click="editLink(1,'20')"></i>
        </div>
      </div>

      <div v-for="(item, index) in zyjn" :key="index">
        <div class="point tem_comm">
          <div class="group">
            <i class="iconfont icon-delete" @click="deleteData('20',item)"></i>
            <i class="iconfont icon-edit" @click="editLink(2,'20',item)"></i>
          </div>
          <!-- <div class="item">
            <span class="list_l">技能名称</span>
            <span class="list_r">{{item.yyjnbm_xs}}</span>
          </div> -->
          <div class="item">
            <span class="list_l">技能等级</span>
            <span class="list_r">{{item.jsdj_xs}}</span>
          </div>
          <!-- <div class="item">
            <span class="list_l">从事年限</span>
            <span class="list_r">{{item.csnx}}</span>
          </div> -->
        </div>
      </div>
    </div>
    <!-- 语言能力开始 -->
    <div class="common">
      <div class="title tem_comm">
        <p>语言能力</p>
        <div class="group">
          <i class="iconfont icon-add" @click="editLink(1,'10')"></i>
        </div>
      </div>
      <div v-for="(item, index) in yynl" :key="index">
        <div class="point tem_comm">
          <div class="group">
            <i class="iconfont icon-delete" @click="deleteData('10',item)"></i>
            <i class="iconfont icon-edit" @click="editLink(2,'10',item)"></i>
          </div>
          <div class="item">
            <span class="list_l">具有外语</span>
            <span class="list_r">{{item.yyjnbm_xs}}</span>
          </div>
          <!-- <div class="item">
            <span class="list_l">熟练程度</span>
            <span class="list_r">{{item.slcd_xs}}</span>
          </div> -->
          <div class="item" v-if="item.xgsm">
            <span class="list_l">其他外语</span>
            <span class="list_r">{{item.xgsm}}</span>
          </div>
        </div>
      </div>
    </div>
    <!-- <div style="width:100%; text-align: center">
      <button class="btn addbtn" @click="editLink(1)">新增学习经历</button>
    </div> -->
  </div>
</template>
<script>
import $ from "@/common/js/axios";
import store from "@/store/index";
export default {
  name: "workHistory",
  components: {},
  data() {
    return {
      grqzid: "",
      xxjl: [],
      yynl: [],
      zyjn: [],
      whcd:"",
      addObj: {}
    };
  },
  methods: {
    GET_grqzid() {
      this.$loading = true;
      $.get("/grgl/grxqCx")
        .then(res => {
          const data = res.returnData;
          this.grqzid = data.jbxx.grqzid;
          this.jsj = data.jsj;
          this.yynl = data.yynl;
          this.zyjn = data.zyjn;
          this.addObj.grqzid = data.jbxx.grqzid;
          this.addObj.jlid = data.jlid;
          this.whcd = data.jbxx.whcd; //新增时，默认带回
          if(this.grqzid){
            this.GET_getInfo();
          }
        })
        .finally(() => {
          this.$loading = false;
        });
    },
    GET_getInfo() {
      this.$loading = true;
      $.get("/grgl/xxjlCx", {
        params: {
          grqzid: this.grqzid
        }
      })
        .then(res => {
          const data = res.returnData;
          this.xxjl = data.xxjl;
        })
        .finally(() => {
          this.$loading = false;
        });
    },
    editLink(operaFalg, lx, item) {
      store.commit("SET_FORJUMP_GO", true);//添加标识 ，手机返回 避免循环跳转
      if (lx == '40') {
        this.addObj.whcd = this.whcd;
      }
      if (operaFalg == 1) {
        this.addObj.yyjnlx = lx;
        this.addObj.ywcz = operaFalg;
        this.$router.push({ path:'/user/resume/editSchoolExper', query: this.addObj })
      } else {
        item.ywcz = operaFalg;
        item.yyjnlx = lx;
        item.grqzid = this.grqzid;
        this.$router.push({ path:'/user/resume/editSchoolExper', query: item })
      }
    },
    deleteData(lx, item) {
      var _url = '';
      item.grqzid = this.grqzid;
      item.ywcz = '0';
      this.$confirm('确定要删除吗？', '提示')
      .then(() => {
        this.$loading = true;
        if(lx == '40'){
          _url = '/grgl/xxjlBc';
        }else{
          _url = '/grgl/zyjnBc';
        }
        this.$http.post(_url, item).then(res => {
          const resData = res.returnData;
          this.$alert(resData.message, () => {
            this.GET_grqzid();
          });
        }).finally(() => {
          this.$loading = false;
        });
      })
      .catch(() => {
        this.$toast('选择了取消');
      });
    },
    back_btn(){
      this.$router.push({name:'userResume'});
    }
  },
  // 跳转上一个页面  判断是否返回我的 禁止循环跳转
  /* eslint-disable consistent-return */
  beforeRouteLeave(to, from, next) {
    this.$nextTick(_ => {
      if (to.name == "UserResumeeditSchoolExper" && !store.state.forjump) {
        next({ name: "userResume" });
      } else {
        store.commit("SET_FORJUMP_GO", false);
        next();
      }
    });
  },
  created() {
    this.GET_grqzid();
    // 隐藏home按钮
    this.$store.commit('SET_VISIBLE_ALL', false);
  }
};
</script>
<style scoped lang="scss">
@import "~common/scss/var.scss";
.wrap {
  background: $color-bg;
  .btn-wrap {
    display: flex;
    .weui-btn {
      margin: $margin-base auto;
      flex: 0 1 47%;
    }
  }
}

.point.tem_comm {
  margin-top: 20px;
  border-bottom: 1px dotted #ccc;
}
</style>
